#include<iostream>
using namespace std;
typedef char ElemType;
typedef struct linknode
{
	ElemType data;
	struct linknode *next;
}LiStack;
void InitStack(LiStack *&s){
    s=new LiStack;
    s->next=NULL;
}
void destory(LiStack *&s){
	LiStack *p=s,*q=p->next;
	while(q!=NULL){
		delete p;
		p=q;
		q=p->next;
	}
    delete p;
}
/*void push(LiStack *&s,char e){
	LiStack *p;
	p=new LiStack;
	p->data=e;
	p->next=s->next;
	s->next=p;
}*/
void Push(LiStack *&s,char e)
{
	LiStack *p;
	p = new LiStack;
	p->data = e;
	p->next = s->next;
	s->next = p;
}

bool pop(LiStack *&s,ElemType &e){
	LiStack *p;
    if(s->next==NULL)
        return false;
        p=s->next;
        e=p->data;
        s->next=p->next;
        delete p;
        return true;
}
bool GetTop(LiStack *&s,char e){
    if(s->next==NULL)
        return false;
        e=s->next->data;
        return true;
}
bool match(LiStack *&S,char &c)
{
	char e;
    int flag=1,t=1,i;
    char str[1000];
    while(gets(str))
    {
        if(str[0]=='.'&&str[1]=='\n')
            break;
        for(i=0; str[i]!='\0'; i++)
        {
            if(str[i]=='('||str[i]=='['||str[i]=='{')
                Push(S,str[i]);
            if(str[i]=='/'&&str[i+1]=='*')
            {
                Push(S,str[i]);
                Push(S,str[i+1]);
                i+=2;
            }
            if(str[i]==')')
            {
                if(S->next!=NULL && S->next->data=='(')
                    pop(S,e);
                else
                {
                    c=str[i];
                    flag=0;
                    break;
                }
            }
            if(str[i]==']')
            {
                if(S->next!=NULL && S->next->data=='[')
                    pop(S,e);
                else
                {
                    c=str[i];
                    flag=0;
                    break;
                }
            }
            if(str[i]=='}')
            {
                if(S->next!=NULL && S->next->data=='{')
                    pop(S,e);
                else
                {
                    c=str[i];
                    flag=0;
                    break;
                }
            }
            if(str[i]=='*'&&str[i+1]=='/')
            {
                if(S->next!=NULL && S->next->data=='*')
                {
                    pop(S,e);
                    if(S->next!=NULL && S->next->data=='/')
                        pop(S,e);
                    else
                    {
                        c=str[i];
                        flag=0;
                        break;
                    }
                }
                else
                {
                    c=str[i];
                    flag=0;
                    break;
                }
            }
           
        }
    }
    if((S->next==NULL)&&(flag==1))
        return true;
    else
        return false;
}
int main(){
	char c;
	LiStack *S;
    InitStack(S);
    if(match(S,c))
        cout<<"YES"<<endl;
    else
    {
        cout<<"NO"<<endl;
        if(S->next!=NULL)
        {
            if(S->next->data=='(')
                cout<<'('<<'-'<<'?';
            else if(S->next->data=='[')
                cout<<'['<<'-'<<'?';
            else if(S->next->data=='{')
                cout<<'{'<<'-'<<'?';
            else if(S->next->data=='*')
                cout<<'/'<<'*'<<'-'<<'?';
        }
        else
        {
            if(c==')')
                cout<<'?'<<'-'<<')';
            else if(c==']')
                cout<<'?'<<'-'<<']';
            else if(c=='}')
                cout<<'?'<<'-'<<'}';
            else if(c=='*')
                cout<<'?'<<'-'<<'*'<<'/';
        }
    }
	return 0; 

}
